package web.servlet.embed_tomcat;

import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Valve;
import org.apache.catalina.connector.Connector;
import web.server.ConfigurableWebServerFactory;

import java.io.File;
import java.nio.charset.Charset;

/**
 * @author chenkh
 * @time 2020/11/23 15:46
 */
public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServerFactory {
    /**
     * Set the Tomcat base directory. If not specified a temporary directory will be used.
     * @param baseDirectory the tomcat base directory
     */
    void setBaseDirectory(File baseDirectory);

    /**
     * Sets the background processor delay in seconds.
     * @param delay the delay in seconds
     */
    void setBackgroundProcessorDelay(int delay);

    /**
     * Add {@link Valve}s that should be applied to the Tomcat {@link Engine}.
     * @param engineValves the valves to add
     */
    void addEngineValves(Valve... engineValves);

    /**
     * {@link Connector}.
     * @param tomcatConnectorCustomizers the customizers to add
     */
    void addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers);

    /**
     * {@link Context}.
     * @param tomcatContextCustomizers the customizers to add
     */
    void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers);

    /**
     * Set the character encoding to use for URL decoding. If not specified 'UTF-8' will
     * be used.
     * @param uriEncoding the uri encoding to set
     */
    void setUriEncoding(Charset uriEncoding);

}
